﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web;

namespace NRemedy.MVC.UI
{
    //session
    //exception redirection and log
    public class SessionController : Controller
    {
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);
            if (requestContext.HttpContext.Session[UserSession.SessionKey] == null){
                requestContext.HttpContext.Response.StatusCode = 401;
            }
        }

        protected override void ExecuteCore()
        {
            if (HttpContext.Response.StatusCode == 401)
                return;
            else
                base.ExecuteCore();
        }

        public UserSession ARUserSession
        {
            get { return Session[UserSession.SessionKey] as UserSession; }
        }

    }
}
